package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TName;
import com.ruoyi.system.service.ITNameService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * name1Controller
 * 
 * @author SJQ
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/system/name")
public class TNameController extends BaseController
{
    @Autowired
    private ITNameService tNameService;

    /**
     * 查询name1列表
     */
    @PreAuthorize("@ss.hasPermi('system:name:list')")
    @GetMapping("/list")
    public TableDataInfo list(TName tName)
    {
        startPage();
        List<TName> list = tNameService.selectTNameList(tName);
        return getDataTable(list);
    }

    /**
     * 导出name1列表
     */
    @PreAuthorize("@ss.hasPermi('system:name:export')")
    @Log(title = "name1", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TName tName)
    {
        List<TName> list = tNameService.selectTNameList(tName);
        ExcelUtil<TName> util = new ExcelUtil<TName>(TName.class);
        util.exportExcel(response, list, "name1数据");
    }

    /**
     * 获取name1详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:name:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tNameService.selectTNameById(id));
    }

    /**
     * 新增name1
     */
    @PreAuthorize("@ss.hasPermi('system:name:add')")
    @Log(title = "name1", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TName tName)
    {
        return toAjax(tNameService.insertTName(tName));
    }

    /**
     * 修改name1
     */
    @PreAuthorize("@ss.hasPermi('system:name:edit')")
    @Log(title = "name1", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TName tName)
    {
        return toAjax(tNameService.updateTName(tName));
    }

    /**
     * 删除name1
     */
    @PreAuthorize("@ss.hasPermi('system:name:remove')")
    @Log(title = "name1", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tNameService.deleteTNameByIds(ids));
    }
}
